<!--Copyright (C) Kherty.  All rights reserved.-->
<ResourceDictionary
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    x:Class="OpenLS.Chart.UI.ChartLineResources"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
    xmlns:chart="http://schemas.Kherty.com/office/2007/chart" 
  xmlns:chartui="clr-namespace:OpenLS.Chart.UI"
  xmlns:drawing2="clr-namespace:OpenLS.Drawing.UI;assembly=OpenLS.Drawing.UI"
  xmlns:drawingui="clr-namespace:OpenLS.Drawing.UI;assembly=OpenLS.Drawing.UI"
  xmlns:Internals="clr-namespace:OpenLS.Chart.UI.Internals"
  xmlns:Internals1="clr-namespace:OpenLS.Drawing.UI.Internals;assembly=OpenLS.Drawing.UI"
    >



    <Style TargetType ="{x:Type Line}" x:Key="gridLineBaseStyle">
        <Setter Property="Focusable" Value="True"/>
        <Setter Property="Shape.Stroke">
            <Setter.Value>
                <MultiBinding Converter="{x:Static  Internals:ChartConverters.LineFillPropertiesSchemeIndexToBrushConverter}">
                    <Binding RelativeSource="{RelativeSource Self}" Path="(drawing2:DrawingElement.ShapeProperties).LineProperties.LineFillProperties"/>
                    <Binding RelativeSource="{RelativeSource Self}" Path="(drawing2:DrawingElement.ColorScheme)"/>
                </MultiBinding>
            </Setter.Value>
        </Setter>
        <Setter Property="StrokeDashArray" Value="{Binding RelativeSource={RelativeSource Self}, Path=(drawing2:DrawingElement.ShapeProperties).LineProperties.LineDashProperties, Converter={x:Static Internals:ChartConverters.LineDashPropertiesToStrokeDashArrayConverter}}"/>
        <Setter Property="StrokeEndLineCap" Value="{Binding RelativeSource={RelativeSource Self},Path=(drawing2:DrawingElement.ShapeProperties).LineProperties.LineCap, Converter={x:Static Internals1:DrawingConverters.LineCapConverter}}"/>
        <Setter Property="StrokeStartLineCap" Value="{Binding RelativeSource={RelativeSource Self},Path=(drawing2:DrawingElement.ShapeProperties).LineProperties.LineCap, Converter={x:Static Internals1:DrawingConverters.LineCapConverter}}"/>
        <Setter Property="StrokeThickness" Value="{Binding RelativeSource={RelativeSource Self},Path=(drawing2:DrawingElement.ShapeProperties).LineProperties.Width, FallbackValue=1}"/>
        <EventSetter Event="Loaded" Handler="OnGridLineLoaded" />
        <EventSetter Event="MouseDown" Handler="OnGridLineMouseDown"/>
    </Style>
    <DataTemplate DataType="{x:Type chart:NumericValue}" x:Key="horizontalLine">

        <Line 
            Style="{StaticResource gridLineBaseStyle}" 
            Height="{Binding Path=StrokeThickness, RelativeSource={RelativeSource Self}}"
            X2="{Binding RelativeSource={RelativeSource FindAncestor, AncestorType={x:Type ItemsControl}}, Path=ActualWidth}"
            />
        <!--<Line 
            Style="{StaticResource gridLineBaseStyle}" 
            Height="{Binding Path=StrokeThickness, RelativeSource={RelativeSource Self}}"
            Y1="{Binding RelativeSource={RelativeSource Self},Path=(drawing2:DrawingElement.ShapeProperties).LineProperties.Width, Converter={x:Static Internals:ChartConverters.HalfConverter}, FallbackValue=0.5}"
            Y2="{Binding RelativeSource={RelativeSource Self},Path=(drawing2:DrawingElement.ShapeProperties).LineProperties.Width, Converter={x:Static Internals:ChartConverters.HalfConverter}, FallbackValue=0.5}"
            X2="{Binding RelativeSource={RelativeSource FindAncestor, AncestorType={x:Type ItemsControl}}, Path=ActualWidth}"
            />-->
    </DataTemplate>
    <DataTemplate DataType="{x:Type chart:NumericValue}" x:Key="verticalLine">
        <Line
            Style="{StaticResource gridLineBaseStyle}" 
            Width="{Binding Path=StrokeThickness, RelativeSource={RelativeSource Self}}"
            Y2="{Binding RelativeSource={RelativeSource FindAncestor, AncestorType={x:Type ItemsControl}}, Path=ActualHeight}"/>
    </DataTemplate>

    <Style TargetType="{x:Type ItemsControl}" x:Key="GridStyle" >
        <Setter Property="chartui:AxisElement.MajorStep">
            <Setter.Value>
                <MultiBinding Converter="{x:Static Internals:ChartConverters.MinMaxToMajorStepConverter}">
                    <Binding RelativeSource="{RelativeSource Self}" Path="(chartui:AxisElement.Minimum)"/>
                    <Binding RelativeSource="{RelativeSource Self}" Path="(chartui:AxisElement.Maximum)"/>
                </MultiBinding>
            </Setter.Value>
        </Setter>
        <Setter Property="ItemsSource" Value="{Binding RelativeSource={RelativeSource Self}, Path=(chartui:AxisElement.ItemsSource)}"/>
        <Setter Property="ItemTemplate" Value="{StaticResource horizontalLine}"/>
        <Setter Property="ItemsPanel">
            <Setter.Value>
                <ItemsPanelTemplate>
                    <chartui:ValueAxisPanel
                           Minimum="{Binding Path=(chartui:AxisElement.Minimum), RelativeSource={RelativeSource Self}}"
                           Maximum="{Binding Path=(chartui:AxisElement.Maximum), RelativeSource={RelativeSource Self}}"
                           ValueAxisOrientation="{Binding Path=(chartui:AxisElement.AxisOrientation), RelativeSource={RelativeSource Self}}"
                            Orientation="{Binding Path=(chartui:AxisElement.Orientation), RelativeSource={RelativeSource Self}}"
                           x:Name="n1"/>
                </ItemsPanelTemplate>
            </Setter.Value>
        </Setter>
        <Setter Property="ItemContainerStyle">
            <Setter.Value>
                <Style>
                    <Setter Property="chartui:ValueAxisPanel.Value" Value="{Binding Value}"/>
                </Style>
            </Setter.Value>
        </Setter>
        <Setter Property="drawing2:DrawingElement.ColorScheme">
            <Setter.Value>
                <MultiBinding Converter="{x:Static Internals:ChartConverters.OrConverter}">
                    <Binding RelativeSource="{RelativeSource Self}" Path="(drawingui:DrawingElement.Theme).ColorScheme"/>

                    <Binding RelativeSource="{RelativeSource Self}" Path="(drawingui:DrawingElement.ColorScheme)"/>
                </MultiBinding>
            </Setter.Value>
        </Setter>
        <Style.Triggers>
            <DataTrigger Binding="{Binding Path=(chartui:AxisElement.Orientation), RelativeSource={RelativeSource Self}}" Value="Horizontal">
                <Setter Property="ItemTemplate" Value="{StaticResource verticalLine}"/>
            </DataTrigger>
        </Style.Triggers>
    </Style>
    <DataTemplate DataType="{x:Type Internals:ChartLineInfo}">
        <ItemsControl 
            Style="{StaticResource GridStyle}"
            chartui:AxisElement.Axis="{Binding Axis}" ItemsSource="{Binding Values}"
        Name="root" ItemTemplate="{StaticResource horizontalLine}"
            drawingui:DrawingElement.LineProperties="{Binding ChartLines.ShapeProperties.LineProperties}"
            drawingui:DrawingElement.ShapeProperties="{Binding ChartLines.ShapeProperties}">
            <ItemsControl.CommandBindings>
                <CommandBinding Command="{x:Static ApplicationCommands.Delete}" Executed="OnDeleteGridLine"/>
            </ItemsControl.CommandBindings>
            <ItemsControl.ItemsPanel>
                <ItemsPanelTemplate>
                    <chartui:ValueAxisPanel
                           Minimum="{Binding Minimum}"
                           Maximum="{Binding Maximum}"
                           ValueAxisOrientation="{Binding Path=(chartui:AxisElement.AxisOrientation), RelativeSource={RelativeSource Self}}"
                        Orientation="{Binding Path=(chartui:AxisElement.Orientation), RelativeSource={RelativeSource Self}}"/>
                </ItemsPanelTemplate>
            </ItemsControl.ItemsPanel>
            <ItemsControl.ItemContainerStyle>
                <Style>
                    <Setter Property="chartui:ValueAxisPanel.Value" Value="{Binding Value}"/>
                </Style>
            </ItemsControl.ItemContainerStyle>
        </ItemsControl>
        <DataTemplate.Triggers>
            <DataTrigger Binding="{Binding Path=(chartui:AxisElement.Orientation), RelativeSource={RelativeSource Self}}" Value="Horizontal">
                <Setter TargetName="root" Property="ItemTemplate" Value="{StaticResource verticalLine}"/>
            </DataTrigger>
        </DataTemplate.Triggers>
    </DataTemplate>

</ResourceDictionary>